app.controller('moreController', ['$scope', '$stateParams', '$rootScope', '$state', function($scope, $stateParams, $rootScope, $state) {
		//总项目名称

		$rootScope.product = "/wechat_mt5";
		//滞空要不angular不识别
		$scope.shop = {
			list: " ",
			infoList: "",
			xList: "",
			listMore: "",
			total: ""
		}

		//判断是否登录
		$scope.loginSate = function() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/user/login/status",
				async: false,
				success: function(data) {
					if(data.data.rememberMeStatus || data.data.loginStatus) {
						lookLevel();
						$scope.login = true;
						$scope.userLogin = data.data.mail;

					} else {
						window.location.href = "#/follow/list";
						shopList(0);
						//						window.location.href = "#/";
						$scope.login = false;
					}
					//					$scope.$apply();

				}
			});
		}

		$scope.loginSate();

		var openId;

		//登录页面
		$scope.onlogin = function() {

				if($('#lusername').val() == "" || $('#lpassword').val() == "") {
					prompt("请输入账号密码!");
				} else {
					$.ajax({
						type: "post",
						url: $rootScope.product + "/user/login",
						data: {
							mail: $('#lusername').val(),
							password: $('#lpassword').val(),
							rememberMe: $('#rember')[0].checked

						},
						success: function(data) {

							if(data.code == 0) {
								$scope.userLogin = $('#lusername').val();
								$scope.$apply();
								lookLevel();

							} else if(data.code == 10010001) {
								prompt("用户名或密码错误!");
							}

						},
						error: function(data) {

						}
					});
				}

			}
			//注册页面
		$scope.onzc = function() {
				if($('#zpassword').val() == "" || $('#zpassword2').val() == "") {
					prompt("请输入密码!");
				} else if($('#zpassword').val() != $('#zpassword2').val()) {
					prompt("确认密码错误!");
				} else if($('#zemail').val() == "") {
					prompt("邮箱不能为空!");
				} else if(emailGe($('#zemail').val()) == false) {
					return false;
				} else if($('#zpassword').val().length < 6 || $('#zpassword').val().length > 16) {
					prompt("密码长度6到16位之间！")
				} else {

					$.ajax({
						type: "post",
						url: $rootScope.product + "/user/web/register",
						data: {

							password: $('#zpassword').val(),
							mail: $('#zemail').val(),
							mailValidationCode: $('#zcode').val(),

						},
						success: function(data) {

							if(data.code == 0) {
								if(data.data) {
									$scope.userLogin = $('#zemail').val();
									$scope.$apply();
									lookLevel();
									prompt("恭喜您注册成功！");

								} else {
									prompt("注册失败，请重新注册！");
								}
							} else if(data.code == 10010007) {
								prompt("注册失败，验证码错误！");
							} else if(data.code == 10010014) {
								prompt("注册失败，邮箱已注册！");
							}

						},
						error: function(data) {

						}
					});
				}

			}
			//邮箱是否重复
		function repeatMail() {

			$.ajax({
				type: "get",
				url: $rootScope.product + "/user/validate/mail",

				data: {
					mail: $('#zemail').val()
				},
				success: function(data) {
					if(data.data) {
						prompt("此邮箱已注册")

					}
				}
			});
		}

		//邮箱格式

		//			lookLevel();
		//查看状态 （是否绑定过）
		function lookLevel() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/mt/user/find/mt/info",
				data: {
					openId: openId

				},
				success: function(data) {

					if(data.code == 0) {
						if(data.data == "") {
							window.location.href = "#/level"
						} else {
							clearAll();
							$scope.login = true;
							//0是大牛
							if(data.data.type == "0") {
								window.location.href = "#/daniel/list";

							} else {
								window.location.href = "#/follow/list";

							}

							$scope.mtLogin = data.data.mtLogin;
							//waite  是否能看我的订单
							$scope.waite = true;
							$scope.dontGen = false;

							if(data.data.state == "1") {
								$scope.waite = false;
								$scope.dontGen = true;
								prompt("您申请绑定的账号" + $scope.mtLogin + "，正在审核中！请耐心等待");

							} else if(data.data.state == "2") {

								$scope.waite = false;
								$scope.dontGen = true;
								prompt("您申请绑定的账号" + $scope.mtLogin + "，未通过！请核对信息后重新绑定");

							}
							genCan();
							shopList(0);
							myInfo();

							$scope.$apply();
						}

					}

				},
				error: function(data) {

				}
			});
		}
		//更改密码
		$scope.changePass = function() {
				if($('#changepassword2').val().length < 6 || $('#changepassword2').val().length > 16) {
					prompt("密码长度6到16位之间！")
				} else {
					$.ajax({
						type: "put",
						url: "/wechat_mt5/user/update/pwd",
						data: {
							password: $("#changepassword1").val(),
							newPassword: $("#changepassword2").val(),
							flag: 1
						},
						success: function(data) {
							if(data.data) {

								window.location.href = "#/";
								window.location.reload();
								prompt("更改成功");

							} else {
								prompt("密码错误")
							}
						}
					});
				}
			}
			//点击变更账户
		$scope.changeAccount = function() {
				bangAccount();
				alertNew("切换账号", 330, 500, $("#changeId"));
			}
			//切换账号列表
		function bangAccount() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/mt/user/get/mts",
				data: {
					openId: openId,
				},
				success: function(data) {
					if(data.data) {
						$scope.accountList = data.data;
						for(x in data.data) {
							if(data.data[x].status == "1") {
								$scope.accountList.updateTimeOld = data.data[x].updateTime;
								break;
							}
						}
					}

					$scope.$apply();

				}
			});
		}

		//数据源列表
		$scope.numArr = [];
		//自定义分页

		function splitPageNum(num) {
			for(var i = 1; i < num + 1; i++) {
				$scope.numArr.push(i)
			}

		}

		function shopList(offset) {

			$.ajax({
				type: "get",
				url: $rootScope.product + "/data/web/list",
				async: false,
				data: {
					openId: openId,
					offset: offset,
					limit: 14

				},
				success: function(data) {
					//					console.log(data.data.slice(0,3))

					$scope.shopList = data.rows;
					$scope.shop.total = Math.ceil(data.total / 14)

					sessionStorage.setItem("total", $scope.shop.total)
					splitPageNum($scope.total);

					//					$scope.$apply();

				}
			});

		}

		function pageList(offset) {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/data/web/list",
				data: {
					openId: openId,
					offset: offset,
					limit: 14

				},
				success: function(data) {
					$scope.shopList = data.rows;
					$scope.$apply();

				}
			});
		}
		//分页点击
		$scope.changePag = function(x) {
			$scope.shop.listMore = x;
			var offset = (x - 1) * 14
			pageList(offset)
		}
		$scope.test = function() {
			console.log($('#light-pagination'))
		}
		$scope.test();

		//点击分页开头
		$scope.begain = function(x) {
				$scope.shop.listMore = x;
				pageList(0)
			}
			//分页结尾
		$scope.after = function(x) {
				$scope.shop.listMore = x;
				pageList(($scope.total - 1) * 14)
			}
			//查看更多
		$scope.moreList = function(id, x, all, type) {

				$scope.moreshopListName = x;
				$scope.shopMoreId = id;
				$scope.shopMoreAll = all;

				//当前持仓
				//				$scope.moreId=id;
				sessionStorage.setItem("moreId", id);
				window.location.href = "#/follow/more"
									if(type == 0) {
										window.location.href = "#/daniel/more"
					
									} else {
										window.location.href = "#/follow/more"
					
									}

			}
			//点击切换大牛的订单、历史、个人资料

		$scope.changeShopList = function(choose) {
				$scope.shop.list = choose;

				switch(choose) {
					case 2:
						shopHistory();
						break;
					case 3:
						shopMoreInfo();
						break;

				}
			}
			//点击切换个人的订单、历史、个人资料
		$scope.changeInfoList = function(choose) {
			$scope.shop.infoList = choose;

			switch(choose) {
				case 2:
					myHistory()
					break;
				case 3:
					myInfo();
					break;

			}
		}

		function myHistory() {
			$('#myChiHistory').bootstrapTable({
				url: "/wechat_mt5/mt/user/web/myself/history",
				method: 'get',
				columns: [{
					field: 'name',
					title: '名称',
					formatter: txFuction
				}, {
					field: 'order',
					title: '订单编号',

				}, {
					field: 'symbol',
					title: '交易品种',

				}, {
					field: 'cmd',
					title: '类别',
					formatter: type

				}, {
					field: 'volume',
					title: '手数',
					formatter: hand

				}, {
					field: 'openTime',
					title: '开仓时间',
					formatter: date

				}, {
					field: 'openPrice',
					title: '开仓价格',
				}, {
					field: 'closeTime',
					title: '平仓时间',
					formatter: date

				}, {
					field: 'closePrice',
					title: '平仓价格',
				}, {
					field: 'point',
					title: '获利点数',
					formatter: ponity
				}, {
					field: 'profit',
					title: '收益金额($)',
					formatter: money
				}],
				height: 650,
				pageSize: 10,
				pageList: [10, 25, 50, 100],
				showRefresh: true,
				editable: true,
				// onClickRow:operateEvents,
				// showColumns: true,
				pagination: true,
				//		  striped: true,
				sidePagination: 'server',

			});
		}
		$scope.changeMowList = function(choose) {
				$scope.shop.infoList = choose;
				console.log(choose)

				switch(choose) {

					case 3:
						shopMoreInfo();
						break;

				}
			}
			//大牛列表更多之持仓
		$scope.shopPing = [];

		function shopChi() {

			var type = window.location.hash;
			$.ajax({
				type: "get",
				url: $rootScope.product + "/data/more/position",
				data: {
					mtLogin: $scope.shopMoreId,
					offset: shop_chiOffset

				},
				success: function(data) {

					if(data.code == 0) {
						if(data.data.length == 0) {
							$scope.noShuChi = true;
							$scope.shopPing = "";
							$scope.shop_noChiList = false;
						} else {
							$scope.noShuChi = false;

							$scope.shop_noChiList = scrollFuction($scope.shopPing, data.data, $scope.shop_noChiList);

						}

						if(type.indexOf("#/follow") != -1) {
							window.location.href = "#/follow/more"

						} else {
							window.location.href = "#/daniel/more"
						}

					}

					$scope.$apply();

				}
			});
		}

		//大牛列表更多之历史记录

		function shopHistory() {
			$('#myChiHistory').bootstrapTable({
				url: "/wechat_mt5/data/web/more/history",
				method: 'get',
				queryParams: {
					mtLogin: sessionStorage.getItem("moreId")
				},
				columns: [{
					field: 'name',
					title: '名称',
					formatter: txFuction
				}, {
					field: 'order',
					title: '订单编号',

				}, {
					field: 'symbol',
					title: '交易品种',

				}, {
					field: 'cmd',
					title: '类别',
					formatter: type

				}, {
					field: 'volume',
					title: '手数',
					formatter: hand

				}, {
					field: 'openTime',
					title: '开仓时间',
					formatter: date

				}, {
					field: 'openPrice',
					title: '开仓价格',
				}, {
					field: 'closeTime',
					title: '平仓时间',
					formatter: date

				}, {
					field: 'closePrice',
					title: '平仓价格',
				}, {
					field: 'point',
					title: '获利点数',
					formatter: ponity
				}, {
					field: 'profit',
					title: '收益金额($)',
					formatter: money
				}],
				height: 650,
				pageSize: 10,
				pageList: [10, 25, 50, 100],
				showRefresh: true,
				editable: true,
				// onClickRow:operateEvents,
				// showColumns: true,
				pagination: true,
				striped: true,
				sidePagination: 'server',

			});
		}
		//大牛列表详情
		function shopMoreInfo() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/data/more/details",
				data: {
					mtLogin: $scope.shopMoreId,
				},
				success: function(data) {

					if(data.code == 0) {

						if(data.data) {

							$scope.shopMoreInfo = data.data[0];

						}

					}

					$scope.$apply();

				}
			});
		}

		$scope.goonList = function() {
			window.location.href = "#/documentary";

		}

		//个人当前持仓

		function chiNull() {
			$scope.myChi = [];
			chi();
		}

		$scope.myChi = [];

		function chi() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/mt/user/myself/position",
				data: {
					openId: openId,
					offset: my_chiOffset
				},
				success: function(data) {

					if(data.code == 0) {
						if(data.data.length == 0) {
							$scope.noRecord = true;
							$scope.hasRecord = false;

							$scope.info_noChiList = false;

						} else {

							$scope.hasRecord = true;

							$scope.noRecord = false;
							//						$scope.myChi = data.data;
							$scope.info_noChiList = scrollFuction($scope.myChi, data.data, $scope.info_noChiList);
							$scope.$apply();

						}
					}
					//					else if(data.code == 10030001) {
					//						lookLevel();

					//						prompt("您还没有审核成功的mt账号,请重新绑定！")
					//					} 
					else {
						$scope.myChi = "";
					}

					$scope.$apply();

				}
			});
		}

		//个人历史记录

		//点击个人时候
		$scope.changeInfo = function() {
				$scope.myChi = [];
				$scope.myHistory = [];
				lookLevel();
				//更新个人持仓
				chi();
				myHistory();

				myInfo();

				//个人历史	 
				//			var type = window.location.hash;
				//			if(type.indexOf("#/follow") != -1) {
				//				window.location.href = "#/follow/info"
				//			} else {
				//				window.location.href = "#/daniel/info"
				//			}

			}
			//点击数据源
		$scope.listShopDown = function(type) {
			$scope.shopList = [];
			$scope.lodading = true;
			offset = 0;
			shopList();
			genCan();

			if(type == 1) {

				window.location.href = "#/follow/list";

			} else {

				window.location.href = "#/daniel/list";

			}

		}

		//平仓按钮
		$scope.ping = function(id) {
			mui.confirm("您确定要平仓吗？", function(e) {
				if(e.index == "1") {
					$.ajax({
						type: "put",
						url: $rootScope.product + "/mt/user/close/trade",
						data: {
							order: id,
						},
						success: function(data) {
							if(data.code == 0) {
								if(data.data) {
									$scope
									$scope.myChi = [];
									$scope.myHistory = [];
									chi();
									myHistory();
									prompt("平仓成功！");

								} else {
									prompt("平仓失败！");
								}

								$scope.$apply();
							}

						}
					});
				}
			})
		}

		function clearAll() {

			$scope.waiteNo = false;
			$scope.noRecord = false;
			$scope.hasRecord = false;
			$scope.noLu = false;
			$scope.hasLu = false;
			$scope.hasInfo = false;
		}
		$scope.changeState = function(id, state, type, newTime, oldTime) {
			console.log(type)
			if(state == "1") {
				//				$scope.waite = true;
				//			$scope.mtLogin = id;
				prompt("您账号" + id + "正在审核中！");

			} else if(state == "2") {
				//				$scope.waiteNo = true;
				prompt("您账号" + id + "审核失败！");
			} else {
				$.ajax({
					type: "put",
					url: $rootScope.product + "/mt/user/update/online",
					data: {
						openId: openId,
						mtLogin: id,
						updateTimeOld: oldTime * 1,
						updateTimeNew: newTime * 1
					},
					success: function(data) {
						if(data.code == 0) {

							if(type == "1") {
								window.location.href = "#/follow/info";
							} else {
								window.location.href = "#/daniel/info";
							}

							window.location.reload();
						} else {
							prompt("切换失败");

						}

					}
				});

			}

		}

		//	myInfo();
		//个人信息

		function myInfo() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/mt/user/myself/details",
				data: {
					openId: openId,
				},
				success: function(data) {

					if(data.code == 0) {
						$scope.infoList = data.data[0];

						$scope.dontGen = false;

						$scope.available = '0';
					}
					//					else if(data.code == 10030001) {
					//					    clearAll();
					//						prompt("您还没有审核成功的mt账号,请重新绑定！")
					//					}
					else {
						//     if(data.error.code=="700020040"){
						//				$scope.waite=true;
						//     	 
						//     }
						if(data.error.code == "700020027") {

						}
						$scope.infoList = data.data;
						$scope.available = '1';
						$scope.dontGen = true;
					}
					$scope.$apply;
				}
			});
		}

		//跟单设置
		$scope.changeSet = function(num, id) {
			if($scope.login == false) {
				window.location.href = "#/"
			} else {
				if(num == 1) {
					$scope.noCansel = true;
					$scope.gendan = true;
					$scope.xiugai = false;
					alertNew("跟单设置", 700, 600, $("#genSet"));
				} else {
					$scope.xiugai = true;
					$scope.gendan = false;
					$scope.noCansel = false;

					$.ajax({
						type: "get",
						url: $rootScope.product + "/follow/get/param",
						data: {
							sourceLogin: id,
							openId: openId
						},
						success: function(data) {

							if(data.data) {

								$scope.maxmoney = data.data.rate;
								$scope.dontCM = $scope.maxmoney + $scope.dontCM
								$scope.gendanTime = data.data.updateTime;
								//							$scope.bringId = data.data.id;
								alertNew("跟单设置", 700, 600, $("#genSet"));

								if(data.data.type == 1) {
									$scope.typeColor = "bgGreen";

								} else {
									$scope.typeColor = "lightGray";

								}

							}
							$scope.$apply();

						}
					});

				}
			}

			$scope.sureHasId = id
				//		$scope.$apply($scope.sureHasId)

		}

		//确定跟单
		$scope.sureGoShop = function(service) {

				// 0 跟单  1 修改
				var type;
				if($('#pingChoose .yesBtn').hasClass("bgGreen")) {
					type = 1;
				} else {
					type = 0;
				}

				if($scope.maxmoney > 0) {
					if(service == 0) {
						$.ajax({
							type: "post",
							url: $rootScope.product + "/follow/create/param",
							data: {
								openId: openId,
								type: type,
								rate: $scope.maxmoney,
								sourceLogin: $scope.sureHasId,

							},
							success: function(data) {

								if(data.code == 0) {
									$scope.shopList = [];
									offset = 0
									shopList();
									window.location.reload();
									prompt("跟单成功！");

								} else {
									prompt("跟单失败！");
								}
							}
						});
					} else {
						$.ajax({
							type: "put",
							url: $rootScope.product + "/follow/update/param",
							data: {
								sourceLogin: $scope.sureHasId,
								type: type,
								rate: $scope.maxmoney,
								openId: openId,
								updateTime: $scope.gendanTime

							},
							success: function(data) {

								if(data.code == 0) {
									$scope.shopList = [];
									offset = 0;
									shopList();
									window.location.reload();
									prompt("更改成功！");
									genCan();

								} else {
									prompt("更改失败！");
								}

							}
						});
					}
				} else {
					prompt("跟单比例不能为0")
				}
			}
			//取消跟单
		$scope.canselGen = function() {

			var type;
			if($('#canselList .choose').hasClass('chooseYes')) {

				if($('#canselList .chooseYes').prev().html() == '立即平仓正在跟随的订单并解除跟单') {
					type = 1;
				} else {
					type = 2;
				}
			}

			$.ajax({
				type: "post",
				url: $rootScope.product + "/follow/delete/param",
				data: {

					riskType: type,
					sourceLogin: $scope.sureHasId,
					openId: openId

				},
				success: function(data) {
					if(data.code == 0) {
						$scope.shopList = [];
						offset = 0;
						shopList();
						prompt("取消成功！");
						genCan();
						window.location.reload();

					} else {
						prompt("取消失败！");
					}

				}
			});

		}

		$scope.canselGenPage = function() {
			layer.close(layer.index);
		}

		function genCan() {
			$.ajax({
				type: "get",
				url: $rootScope.product + "/mt/user/get/myself/rate/surplus",
				data: {
					openId: openId,
				},
				success: function(data) {
					console.log(data);

					if(data.code == 0) {
						$scope.money = data.data.value;
						$scope.maxmoney = data.data.rate;
						$scope.dontCM = data.data.rate;

					}
				}
			});
		}
		//设置跟单参数

		$scope.setCount = function() {
			$scope.newMoney = ($scope.money * $scope.maxmoney / 100).toFixed(2);
			alertNew("跟单设置", 450, 300, $("#moreGen"));
			$scope.sureNumber = function() {

				layer.close(layer.index);
				$scope.maxmoney = $('#myNumber').val();

			}

			$scope.canselNumber = function() {
				layer.close(layer.index);
			}
			$(function() {
				$('#myNumber').bind('input propertychange', function() {

					var re = /\./g
					if($(this).val() % 1 != 0) {
						prompt("请输入整数！");
						$(this).val(0)
					}

					if(re.test($(this).val())) {
						prompt("请输入整数！");
						$(this).val(0)
					}
					if($(this).val() > 100) {
						mui.alert("100%以上的跟单比例，扩大收益的同时也会增加风险，请谨慎。");
					}

					if($(this).val() > $scope.dontCM) {
						prompt("最大跟单比例为" + $scope.dontCM + "%");
						$(this).val($scope.dontCM);
						$('#changeMoney').html("$" + $scope.newMoney)
					} else if($(this).val() < 0) {
						prompt("最小跟单比例为1%");
						$(this).val(1);
						var num = $(this).val() / 100 * $scope.money;
						$('#changeMoney').html("$" + num.toFixed(2))
						$('#changeMoney').html("$" + num.toFixed(2))

					} else {
						var num = $(this).val() / 100 * $scope.money;
						$('#changeMoney').html("$" + num.toFixed(2))
					}

				})
			})

		}

		$scope.canselList = function() {
			alertNew("取消跟单", 420, 371, $("#canselList"));

			//			window.location.href = "#/canselList"
		}

		//	var bol=true;
		//	if(bol){
		//		event.preventDefault();
		//		window.location.href="#/"
		//	}

		//绑定
		$scope.sureBang = function() {

			var type = window.location.hash.split("?")[1];
			if(type == undefined) {
				if($("#bigHasName").css("display") == "none") {
					type = 1;
				} else {
					type = 0;
				}

			}

			$scope.id = $('#zh').val();

			if(checkAll() == false) {
				return false;
			} else {

				$.ajax({
					type: "post",
					url: $rootScope.product + "/mt/user/binding/mt",

					data: {
						mtLogin: $('#zh').val() * 1,
						mobile: $('#phone').val(),
						type: type,
						name: $('#shopName').val(),
						pwd:$('#pwd').val()

					},
					success: function(data) {
						if(data.code == 0) {
							if(data.data == 0) {
								//						bangAccount();
								lookLevel();
								prompt("<p>您的申请已经提交，我们将在两个工作日开通，请您耐心等候</p>", "账号<span style='color:#2B92D9;margin-left:5px'>" + $scope.id + "</span>");

							} else if(data.data == 1) {
								prompt("此账号已被绑定!");
							} else if(data.data == 2) {

								prompt("请耐心等待上个申请审核通过!");

							} else {
								prompt("操作失败，请稍后重试！");
							}

						}

						if(data.code == 10010007) {
							$('#pass2').val("验证码错误");
							$('#pass2').css("color", "red");
						}
						if(data.code == 10010009) {
							$('#zh').val("请输入正确的MT账号");
							$('#zh').css("color", "red");
						}

					}
				});

			}
		}

		//大牛列表排行榜
		$scope.changeRank_win = function(num) {
			$scope.shop.xList = num;
		}

		$scope.rankSure = function() {
			var num
			$('#screen .box').each(function() {
				if($(this).hasClass("active")) {
					var olTxt = $(this).children("p").text();
					$(".getWin").each(function(x, y) {
						var newTxt = $(".getWin").eq(x).children("p").text()
						if(newTxt == olTxt) {
							num = $(this)[0].outerHTML.split("==")[1].split("}")[0];
						}
					})

					//					.children()
				}

			})
			num *= 1;

			if(num >= 4 && num <= 8) {
				oWidth = ($(window).width() - $(".more").width()) + "px";

				$("#scrollIn .mui-row").css("right", oWidth)
			}
			if(num > 8 && num <= 10) {
				oWidth = ($(window).width() - $(".more").width()) * 2 + "px";

				$("#scrollIn .mui-row").css("right", oWidth)
			}
			$scope.shop.xList = num;
			$("#mask").hide();
			$("#screen").hide();;

			//		  $(function() {
			//			 
			//			 
			//		 })
		}

		$.ajaxSetup({
			complete: function(jqXHR) {

				if(jqXHR.status == 304) {

					window.location.href = "#/"
				}
				var shielding = [902, 901, 304, 903, 401]; //拦截状态码

				if(shielding.indexOf(jqXHR.status) != -1) {
					window.location.href = "#/";
					window.location.reload();

				}
			},
			error: function(jqXHR, textStatus, errorThrown) {

				var shielding = [902, 901, 304, 903, 401]; //拦截状态码
				if(shielding.indexOf(jqXHR.status) != -1) {
					window.location.href = "#/";

				}
			}
		});

		//自定义前三个月时间
		$scope.yearArr = [];
		var today = new Date();
		var year = today.getFullYear()
		var month = today.getMonth() + 1;
		var day = today.getDate();

		function getMonthT(m) {
			return(year - 1) + "-" + m
		}

		function getMonthT2(m) {
			return year + "-" + m

		}

		if(month - 3 < 0) {
			$scope.yearArr.push(date2(today))

			for(var i = 1; i < 4; i++) {
				if(12 + (month - i) == 13) {
					$scope.yearArr.push(getMonthT2(1))

				} else if(12 + (month - i) == 14) {
					$scope.yearArr.push(getMonthT2(2))
				} else if(12 + (month - i) == 15) {
					$scope.yearArr.push(getMonthT2(3))
				} else {
					$scope.yearArr.push(getMonthT(12 + (month - i)))

				}

			}

		} else if(month - 3 == 0) {
			$scope.yearArr.push(date2(today));
			for(var i = 1; i < 3; i++) {
				$scope.yearArr.push(getMonthT(month - i))
			}
			$scope.yearArr.push(getMonthT(12))

		} else {
			$scope.yearArr.push(date2(today));
			for(var i = 1; i < 4; i++) {
				$scope.yearArr.push(getMonthT(month - i))
			}

		}

	}])
	//自定义交易时长
app.filter('transactionDay', function() {
		return function(value) {
			var start = new Date(value);
			var end = new Date();
			var difference = end.getTime() - start.getTime()
			return days = Math.floor(difference / (24 * 3600 * 1000)) + "天"

		}
	})
	//下拉刷新